<?php

use yii\db\Migration;
use yii\db\Schema;

class m170612_054538_ADD_TABLE_ORDER_PRICE extends Migration
{
    public function up()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

        // 订单附加费
        $this->createTable('order_price', [
            "id" =>           Schema::TYPE_PK,
            "desc" =>         Schema::TYPE_STRING.    "(255) NULL COMMENT '费用说明'",
            "price" =>        Schema::TYPE_DECIMAL.   "(10,2) DEFAULT NULL COMMENT '金额 单价'",
            "num" =>     	  Schema::TYPE_INTEGER.   "(4) DEFAULT  '1' COMMENT '数量'",
            "total_price" =>  Schema::TYPE_DECIMAL.   "(10,2) DEFAULT NULL COMMENT '总金额= 单价*数量'",
            "status" =>       Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "user_id" =>      Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" =>   Schema::TYPE_DATETIME.  " NULL",
            "updated_at" =>   Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);


        $this->addColumn('{{order}}', 'price_desc', Schema::TYPE_STRING. "(255) null COMMENT '优惠说明' ");

    }

    public function down()
    {
        echo "m170612_054538_ADD_TABLE_ORDER_PRICE cannot be reverted.\n";

        return false;
    }


}
